package com.ionehe.group.common.io;

import com.fasterxml.jackson.databind.util.StdConverter;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Copyright (c) 2020 ionehe.com
 * Date: 2020/9/22
 * Time: 下午10:35
 *
 * @author 2020年 <a href="mailto:a@ionehe.com">秀</a>
 */
public class ResponseTimestampStringConverter extends StdConverter<Date, String> {
    static final SimpleDateFormat FORMAT;

    public ResponseTimestampStringConverter() {
    }

    @Override
    public String convert(Date value) {
        return "" + (null != value ? value : new Date()).getTime();
    }

    static {
        FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSSZZZZZ", Locale.ENGLISH);
    }
}
